#include "vertex_types.fxh"
#include "Samplers.fxh"

float4x4 g_WorldViewProjectionMatrix : WORLD_VIEW_PROJECTION_MATRIX;

/*struct mainVS
{
	float3 Position : POSITION;
	float2 UV : TEXCOORD0;
};*/

struct mainPS
{
	float4 HPosition : POSITION;
	float2 UV : TEXCOORD0;
	float2 UV2: TEXCOORD1;
	float3 WorldNormal: TEXCOORD2;
};


mainPS RenderVS(TNORMAL_COLORED_2TEXTURED_VERTEX_VS IN)
{
	mainPS OUT=(mainPS)0;
    OUT.HPosition=mul(float4(IN.Position,1.0),g_WorldViewProjectionMatrix);
    OUT.UV=IN.UV;
	OUT.UV2=IN.UV2;
	OUT.WorldNormal = IN.Normal;
	//OUT.WorldNormal=IN.Normal;
    //OUT.WorldPosition=mul(float4(IN.Position,1.0), g_WorldMatrix);
    return OUT;
}

float4 RenderPS(mainPS IN) : COLOR
{
//return float4(IN.WorldNormal, 1.0);
	float3 Nn = normalize(IN.WorldNormal); 
	//return float4(Nn,1);
	//return float4(IN.UV.y, 0, 0, 1.0);
	float4 l_tex= tex2D(S0LinearSampler, IN.UV);
	float4 l_LightMap= 2*tex2D(S1LinearSampler, IN.UV2);
	
	return l_tex*l_LightMap;
}


technique tecTexture
{
	pass p0 
	{
		CullMode = None;
		VertexShader = compile vs_3_0 RenderVS();
		PixelShader = compile ps_3_0 RenderPS();
	}
}